//
//  CustomGLKViewController.m
//  EasyARVideo
//
//  Created by xgx on 2017/12/12.
//  Copyright © 2017年 xgx. All rights reserved.
//

#import "CustomGLKViewController.h"
#import "OpenGLView.h"

NSString* targetName;
NSString* jsonPath;
NSDictionary* targetDict;
ARScanFinish arScanFinish;

@interface CustomGLKViewController ()

@end

@implementation CustomGLKViewController {
    OpenGLView *glView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self->glView = (OpenGLView *)self.view;
//    NSLog(@"******GLView************");
    [self->glView setOrientation:self.interfaceOrientation];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    [self->glView start];
//    NSLog(@"*********START*******");
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self->glView stop];
    arScanFinish = nil;
//    NSLog(@"*********stop*******");
}

-(void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
    [self->glView resize:self.view.bounds orientation:self.interfaceOrientation];
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [self->glView setOrientation:toInterfaceOrientation];
}

-(NSString*)getCurTargetName{
    return targetName;
}

-(void)arScanStart : (NSString *) tPath : (NSDictionary * ) tDict{
    jsonPath = tPath;
    targetDict = tDict;
    [self->glView start];
}

- (void)arScanStart:(NSString *)tPath :(NSDictionary *)tDict :(void (^)(NSString*))finishCallBack {
    jsonPath = tPath;
    targetDict = tDict;
    [self->glView start];
    arScanFinish = finishCallBack;
}
@end
